import {_decorator, Button, Component, Node} from 'cc';
import Long from "long";
import {lobby} from "db://assets/script/lobby";
import {ZoneInfo} from "db://assets/script/game/mainui/battle/zone-info";

const {ccclass, property} = _decorator;

@ccclass('ZoneMapPlane')
export class ZoneMapPlane extends Component {


    @property(Button)
    zone10001Btn!: Button

    @property(Button)
    zone10002Btn!: Button

    @property(Button)
    zone10003Btn!: Button

    @property(Button)
    zone10004Btn!: Button

    @property(Button)
    zone10005Btn!: Button

    willMoveFishId: Long | null = null

    init(willMoveFishId: Long | null = null) {
        this.willMoveFishId = willMoveFishId
        this.onEvent()
    }

    onEvent() {
        this.zone10001Btn.node.on(Button.EventType.CLICK, () => this._showZonePlane(Long.fromNumber(10001)))
        this.zone10002Btn.node.on(Button.EventType.CLICK, () => this._showZonePlane(Long.fromNumber(10002)))
        this.zone10003Btn.node.on(Button.EventType.CLICK, () => this._showZonePlane(Long.fromNumber(10003)))
        this.zone10004Btn.node.on(Button.EventType.CLICK, () => this._showZonePlane(Long.fromNumber(10004)))
        this.zone10005Btn.node.on(Button.EventType.CLICK, () => this._showZonePlane(Long.fromNumber(10005)))

    }

    private _showZonePlane(zoneId: Long) {
        const zonePlane = lobby.instance.addUIWithClickMask('prefab/common/zone-info', 0, (node) => node.destroy())
        zonePlane.getComponent(ZoneInfo)!.init(zoneId, this.willMoveFishId)
    }


}